package com.wty.basic.math;

import org.junit.Test;

/**
 * @Author wangtengyu
 * @Create 2018-08-08-13:08
 */
public class MathDemo {


    //求平方根
    @Test
    public void sqrt(){
        System.out.println(Math.sqrt(16));
    }

    //求立方根
    @Test
    public void cqrt(){
        System.out.println(Math.cbrt(64));
    }

    //计算a的b次方
    @Test
    public void pow(){
        System.out.println(Math.pow(2,3));
    }

    //求大
    @Test
    public void max(){
        System.out.println(Math.max(5,14));
    }

    //求小
    @Test
    public void min(){
        System.out.println(Math.min(5,14));
    }

    //绝对值
    @Test
    public void abs(){
        System.out.println(Math.abs(-6));
    }

    //四舍五入
    @Test
    public void round(){
        System.out.println(Math.round(2.5));
        System.out.println(Math.round(2.5));
        System.out.println(Math.rint(3.5));
    }



    //找比该数大的最小整数
    @Test
    public void ceil(){
        System.out.println(Math.ceil(2.5));
        System.out.println(Math.ceil(-2.5));
    }

    //找比该数小的最大整数
    @Test
    public void floor(){
        System.out.println(Math.floor(2.5));
        System.out.println(Math.floor(-2.5));
    }


}
